We are migrating the bug tracker to github Issues. This is now the preferred way to report NASM bugs.

Self-registration is disabled due to spam issue (mail gorcunov@gmail.com or hpa@zytor.com to create an account)

Bug 3392720 - Nested "at" macro usage in an mmacro is not expanded
Summary: Nested "at" macro usage in an mmacro is not expanded
Status: OPEN
Alias: None
Product: NASM
Classification: Unclassified
Component: Assembler (show other bugs)
Version: 2.15.xx
Hardware: All All
: Medium major
Assignee: nobody
URL:
Depends on:
Blocks:
 
Reported: 2020-10-19 08:21 PDT by E. C. Masloch
Modified: 2020-10-19 08:21 PDT (History)
4 users (show)

Obtained from: Built from git using configure
Generated by: ---
Bug category:
Observed for: ---
Regression: ---
Regression since:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description E. C. Masloch 2020-10-19 08:21:49 PDT
Using "at" in a multi-line macro that is itself used as the data parameter of another "at" leaves the inner "at" unexpanded, leading to errors. In the following, the -DERROR -E run shows "..@11.strucstart:" \ "at bar.bar, db 0" which means the inner "at" wasn't expanded, and is then subsequently passed as a literal instruction to the assembler.

$ cat test2.asm

	struc foo
.foo:	resb 1
	endstruc

	struc bar
.bar:	resb 1
	endstruc

	%macro quux 0
	istruc bar
at bar.bar,	db 0
	iend
	%endmacro

	istruc foo
%ifdef ERROR
at foo.foo,	quux
%else
at foo.foo
		quux
%endif
	iend
$ nasm test2.asm
$ nasm test2.asm -DERROR
test2.asm:18: error: parser: instruction expected
$ nasm test2.asm -E
%line 2+1 test2.asm
[absolute 0]
%line 2+0 test2.asm
foo:
%line 3+1 test2.asm
.foo: resb 1
foo_size equ ($-foo)
%line 4+0 test2.asm
[section .text]
%line 5+1 test2.asm

[absolute 0]
%line 6+0 test2.asm
bar:
%line 7+1 test2.asm
.bar: resb 1
bar_size equ ($-bar)
%line 8+0 test2.asm
[section .text]
%line 9+1 test2.asm

%line 15+1 test2.asm

..@7.strucstart:
%line 20+1 test2.asm
times (foo.foo-foo)-($-..@7.strucstart) db 0
%line 20+0 test2.asm

%line 11+0 test2.asm
..@11.strucstart:
%line 12+1 test2.asm
times (bar.bar-bar)-($-..@11.strucstart) db 0
%line 12+0 test2.asm
db 0
%line 13+1 test2.asm
times bar_size-($-..@11.strucstart) db 0
%line 23+1 test2.asm
times foo_size-($-..@7.strucstart) db 0
$ nasm test2.asm -DERROR -E
%line 2+1 test2.asm
[absolute 0]
%line 2+0 test2.asm
foo:
%line 3+1 test2.asm
.foo: resb 1
foo_size equ ($-foo)
%line 4+0 test2.asm
[section .text]
%line 5+1 test2.asm

[absolute 0]
%line 6+0 test2.asm
bar:
%line 7+1 test2.asm
.bar: resb 1
bar_size equ ($-bar)
%line 8+0 test2.asm
[section .text]
%line 9+1 test2.asm

%line 15+1 test2.asm

..@7.strucstart:

times (foo.foo-foo)-($-..@7.strucstart) db 0
%line 18+0 test2.asm
..@11.strucstart:
at bar.bar, db 0
times bar_size-($-..@11.strucstart) db 0
%line 23+0 test2.asm
times foo_size-($-..@7.strucstart) db 0
$ nasm --version
NASM version 2.15.03rc1 compiled on Sep 29 2020
$